using System;
using UnityEngine;
namespace AssemblyCSharp
{
	public class FlagCheckpointStateEnabling : IFSMState
	{
		private GameObject m_go_Flag;
		
		private const float m_EnablingDuration = 2;
		
		private const float m_EnabledHeight = 110;
		
		private float m_ScaledEnabledHeight;
		
		private float m_StartTimeEnabling;
		
		private float m_StartHeight;
		
		public FlagCheckpointStateEnabling (FSMRunner Runner, GameObject obj)
		{
			_Runner = Runner;
			_GameObject = obj;
			_State = (int)FlagCheckpointState.eEnabling;
			m_go_Flag = _GameObject.transform.Find("flag_flag").gameObject;
			m_ScaledEnabledHeight = m_EnabledHeight; //_GameObject.transform.lossyScale.y * m_EnabledHeight;
		}
		
		public override void OnEnter ()
		{
			m_StartTimeEnabling = Time.time;
			m_StartHeight = m_go_Flag.transform.localPosition.y;
			base.OnEnter ();
		}
		
		public override void OnExecute ()
		{
			float TimeParameter = (Time.time - m_StartTimeEnabling) / m_EnablingDuration;
			float NewHeight = Mathf.Lerp(m_StartHeight, m_ScaledEnabledHeight, TimeParameter);
			Vector3 CurrentPosition = m_go_Flag.transform.localPosition;
			CurrentPosition.y = NewHeight;// + _GameObject.transform.position.y;
			m_go_Flag.transform.localPosition = CurrentPosition;
			
			if(TimeParameter >= 1)
			{
				_Runner.SetCurrentState((int)FlagCheckpointState.eEnabled);
			}
			
			base.OnExecute ();
		}
	}
}

